#include "widget.h"
#include <QApplication>


int main(int argc, char *argv[])
{
    QApplication a(argc, argv);
    Widget w;
    //读取ini文件中上一次关闭软件时候的窗口位置和大小：
    QString wstrFilePath = qApp->applicationDirPath() + "/init.ini" ;
    QSettings *settings=new QSettings(wstrFilePath,QSettings::IniFormat);//用QSetting获取ini文件中的数据
    int x = settings->value("Setting/x").toInt();
    int y = settings->value("Setting/y").toInt();
    int width = settings->value("Setting/width").toInt();
    int height = settings->value("Setting/height").toInt();
    bool auto_start = settings->value("Setting/auto_start").toBool();
    bool lock_state = settings->value("Setting/lock_state").toBool();
    bool MessageBox_state = settings->value("Setting/MessageBox_state").toBool();
    bool Change_wallpaper = settings->value("Setting/Change_wallpaper").toBool();
    QString setting_read_date = settings->value("Setting/date").toString();
    w.setting_date_updata(setting_read_date,auto_start,lock_state,MessageBox_state,Change_wallpaper);
    QRect targRect0 = QRect(x,y,331,260);
    QRect targRect = QRect(x,y,width,height);
    if(width == 0|| height == 0 || x<0  || y<0)//如果上一次关闭软件的时候，窗口位置不正常，则本次显示在显示器的正中央
    {
        targRect = targRect0;
    }
    w.setGeometry(targRect);//设置主窗口的大小
    w.setWindowTitle("倒计时");
    w.show();

    return a.exec();
}
